//
//  RootViewController.m
//  UI_09TabBarController
//
//  Created by dllo on 16/3/21.
//  Copyright © 2016年 XWH. All rights reserved.
//

#import "RootViewController.h"
#import "ViewController.h"
#import "SecondViewController.h"
#import "ThirdViewController.h"
#import "NaviTabBarItem.h"

@interface RootViewController ()

@end

@implementation RootViewController

-(instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil{
    
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        
        
        
        self.viewControllers = [self createRootOfVCs];
        
        
        
        
    }
    
    
    
    return self;
}


- (NSArray<UIViewController *>*)createRootOfVCs{
    
    NSMutableArray *arrOfVCs = [NSMutableArray array];
    
    
    
    //第一视图
    
    ViewController *vc = [[ViewController alloc] init];
    
    NaviTabBarItem *navi = [[NaviTabBarItem alloc] initWithRootViewController:vc];
    
    [arrOfVCs addObject:navi];
    [vc release];
    [navi release];
    
    navi.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"第一页" image:[UIImage imageNamed:@"linkMan"] selectedImage:[UIImage imageNamed:@"linkMan1"]];
    
    //第二个视图
    SecondViewController *secondView = [[SecondViewController alloc] init];
    NaviTabBarItem *navSecond = [[NaviTabBarItem alloc] initWithRootViewController:secondView];
    [arrOfVCs addObject:navSecond];
    [secondView release];
    
    secondView.tabBarItem = [[[UITabBarItem alloc] initWithTitle:@"第二页" image:[UIImage imageNamed:@"message"] selectedImage:[UIImage imageNamed:@"message1"]] autorelease];
    
    
    
    //第三个视图
    
    ThirdViewController *thirdView = [[ThirdViewController alloc] init];
    NaviTabBarItem *third = [[NaviTabBarItem alloc] initWithRootViewController:thirdView];
    [arrOfVCs addObject:third];
    [thirdView release];
    
    thirdView.tabBarItem = [[[UITabBarItem alloc] initWithTitle:@"第三页" image:[UIImage imageNamed:@"dynamic"] selectedImage:[UIImage imageNamed:@"dynamic1"]] autorelease];
    
    
    
    return arrOfVCs;
    
}











- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
